<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://m.nxsmartcity.cn/static/web/open/jpasc-0.4.0.js" ></script>
    <script src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"></script>
    <script src="./md5.js"></script>
    <title>Document</title>
</head>
<body>
    
    <p>
      <input type="text" id="tradeNuber">
      <button onclick="settrade()">随机创建订单号</button>
    </p>
    <button onClick="pay('ces21sss323423001')">测试订单</button>
    <p>把key修改了小写</p>
</body>
<script>
    //初始化一下就可以了，
    let vConsole = new VConsole();
    function RndNum(n){
      var rnd="";
      for(var i=0;i<n;i++)
        rnd+=Math.floor(Math.random()*10);
      return rnd;
    }
    function settrade(){
      var t = RndNum(15);
      let out_trade_no = hex_md5(t)
      document.getElementById('tradeNuber').value = out_trade_no;
    }
    function pay(ddh){
        var tradeNubers = document.getElementById('tradeNuber').value;
        if(tradeNubers==''){
          settrade();
          pay();
          return false;
        }
        sc.xingfutongPay({
          app_id:'1356804651881594880',//必填
          merchant_code:'1430100097003',//必填
          store_code:'',
          operator_id:'',
          limit_pay:'',
          out_trade_no:tradeNubers,//自己生成 //必填
          channel:'',
          product:'WECHAT_APP',//必填
          client_ip:'222.240.100.255',//必填
          amount:'1',
          subject:'订单支付',
          body:'订单支付',
          description:'订单支付',
          notify_url:'',
          time_start:'',
          time_expire:'',
          sign_type:'MD5',
          key:'6B0E2B83B96FDD69132786707F81E5B7',

        },res=>{
          if (res.code === 0) {
            // 成功
            console.log('成功');
          } else {
            // 失败
            console.log('失败');
          }
        })
    }
</script>
</html>